<?php

include("connect.php");



$query = "SELECT id, filename, listorder, title, description FROM images";
$result = mysql_query($query);

$doc = new DomDocument('1.0');

// create root node
$root = $doc->createElement('images');
$root = $doc->appendChild($root);

while($array = mysql_fetch_array($result)) {

	// add node for each row
	$occ = $doc->createElement('image');
	$occ = $root->appendChild($occ);
	$occ->setAttribute('listorder', $array['listorder']);

	$child = $doc->createElement('filename');
	$child = $occ->appendChild($child);
	$value = $doc->createTextNode(htmlentities($array['filename']));
	$value = $child->appendChild($value);

	$child = $doc->createElement('title');
	$child = $occ->appendChild($child);
	$value = $doc->createTextNode(htmlentities($array['title']));
	$value = $child->appendChild($value);
	
	$child = $doc->createElement('description');
	$child = $occ->appendChild($child);
	$value = $doc->createTextNode(htmlentities($array['description']));
	$value = $child->appendChild($value);
	
	$child = $doc->createElement('id');
	$child = $occ->appendChild($child);
	$value = $doc->createTextNode(htmlentities($array['id']));
	$value = $child->appendChild($value);

}

$xml_string = $doc->saveXML();

header('Content-Type: application/xml; charset=utf-8');

echo $xml_string;

?>